#include "const.h"

void v_array_push(var_t v, const char *value) {
	if (v->flags & VAR_CONST_BIT)
		return;

	if (v->flags & VAR_SYMLINK_BIT) {
		v_array_push(v->value.symlink, value);
		return;
	}

	if (~v->flags & VAR_ARRAY_BIT)
		return;

	if (v->array.n+1 > v->array.capacity) {
		size_t i;

		v->array.capacity += 32;

		v->array.members = (char **)i_renew((void *)v->array.members,
			v->array.capacity*sizeof(char *));

		for(i=v->array.n; i<v->array.capacity; i++)
			v->array.members[i] = (char *)0;
	}

	v->array.members[v->array.n++] = i_strdup(value);
	v->flags &= ~(VAR_EXPANDEDN_BIT|VAR_ARRAYFETCHED_BIT);
}
